<?php

require("db_config.php");
require("blowfish.php");

if(isset($_REQUEST['myID'])){
$totalMacIds=0;
$curtime=$_SERVER['REQUEST_TIME'];


$con = mysql_connect($db_host,$db_user,$db_password);
if (!$con)
{
	die('Could not connect: ' . mysql_error());
}

mysql_select_db($db_name, $con);
$result = mysql_query("SELECT id FROM software where software_key='".$_REQUEST['myID']."';");
$row=mysql_fetch_array($result);
if($row != null && $row != "")
{
	$software_id=$row['id'];
	$rs=mysql_query("select vi from audit where software_id = ".$software_id." and action='TOKEN-IO:ACCESS' and timestamp between ".($curtime-600)." and ".$curtime." order by timestamp DESC");
	$row=mysql_fetch_array($rs);
	$vi=$row['vi'];
}

$message = array();
$result=mysql_query("select * from t_anandsoftware_security_properties where `key` not 
in ('osName','osVersion','osProductKey','osDriveSerialNumber','osOriginalInstallDate','systemType','physicalMemory','macId') 
and software_id=".$software_id);

while(($row=mysql_fetch_array($result))){
	$message[$row['key']] = $row['value'];
}

mysql_query("insert into audit (software_id,vi,timestamp,action) values ('".$software_id."','".$vi."',".$curtime.",'Update :".sizeof($message)."')");
//var_dump(json_encode($message));
echo bin2hex(encryptString(json_encode($message),$vi));
mysql_close($con);
}
?>